package com.example.cgq.business;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.widget.TextView;

import com.cgq.common.CellPhoneInfo;
import com.cgq.common.CommonFun;
//启动时获得手机信息
public class Bootctivity extends AppCompatActivity {

    private CommonFun mCommonFun;
    private TextView mTextViewHint,t1,t2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bootctivity);

        initData();
        SetScreenSizedata();
        SetDat();
    }

    private void SetDat() {
        mTextViewHint.setText("kuan:" + mCommonFun.GetScreenWidth() + "gao");
        int wedit = mCommonFun.GetScreenWidth();
        mCommonFun.SetWeight(t1, wedit / 2);
    }

    private void initData() {
        mCommonFun = new CommonFun();
        mTextViewHint = (TextView) findViewById(R.id.id_textView_boot);
        t1 = (TextView) findViewById(R.id.id_1);
        t2 = (TextView) findViewById(R.id.id_2);
    }


    public void  OnClickBootButton(View  view) {
        Intent intent = new Intent(Bootctivity.this, MainActivity.class);
        SendThisActivityDataToOther(intent);

        startActivity(intent);
    }


    private void SendThisActivityDataToOther(Intent intent) {

        CellPhoneInfo cellPhoneInfo;
        cellPhoneInfo = new CellPhoneInfo();
        cellPhoneInfo.ScreenHeight = mCommonFun.GetScreenWidth();
        cellPhoneInfo.ScreenWeight = mCommonFun.GetScreenWidth();
        Bundle bundle = new Bundle();
        bundle.putSerializable("CellPhoneInfo",cellPhoneInfo);
        intent.putExtras(bundle);
    }
    private void SetScreenSizedata() {

        DisplayMetrics metric = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metric);
        int width = metric.widthPixels;     // 屏幕宽度（像素）
        int height = metric.heightPixels;   // 屏幕高度（像素）
        //float density = metric.density;      // 屏幕密度（0.75 / 1.0 / 1.5）
        //int densityDpi = metric.densityDpi;  // 屏幕密度DPI（120 / 160 / 240）
        mCommonFun.SetScreenHeight(height);
        mCommonFun.SetScreenWidth(width);
    }
}
